<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<title>Aikes_系统</title>
<!-- CSS -->
<link rel="stylesheet" href="css/login/login-style.css">
<!-- Javascript -->
<script src="css/js/jquery.min.js"></script>
<script type="text/javascript"> 
	$(function() {
		$("#login").click(login);
	});
	
	function login() {
		var username = $('#username').val().trim();
		var password = $('#password').val().trim();
		if (username == "") {
			 $('.error').fadeOut('fast', function(){
	                $(this).css('top', '13px');
	         });
	         $('.error').fadeIn('fast', function(){
	             $("#username").focus();
	         });
		} else if (password == "") {
			$('.error').fadeOut('fast', function(){
               	 $(this).css('top', '95px');
            });
            $('.error').fadeIn('fast', function(){
                $("#password").focus();
            });
		}else {
			$.ajax({
				url : "login.sls",
				type : "post",
				data : {
					"adminCode" : username,
					"password" : password
				},
				dataType : "json",
				success : function(user) {
					if (user.status == 1) {
						$("#count_span").html(user.msg);
					} else if (user.status == 2) {
						$("#pwd_span").html(user.msg);
					} else {
						window.location.href="toIndex.sls";
					}
				},
				error : function() {
					window.location.href="error.sls";
				}
			});
		}
		$('.page-container .form #username, .page-container .form #password').keydown(function(){
		        $(this).parent().find('.error').fadeOut('fast');
		        $("#pwd_span").html("&nbsp;");
		        $("#count_span").html("&nbsp;");
		});
	}
	
	$("html").keydown(function(event){
		var code = event.keyCode;
		if(code == 13){
			login();
		}
		
	});
</script>
</head>

<body> 
	<div class="page-container">
		<h1 style="z-index:20 " >Aikes_系统</h1>
		<div class="form">
			<input type="text" name="username" id="username" placeholder="Username">
			<span id="count_span" style="color: #666;"> &nbsp;</span>
			<input type="password" name="password" id="password" placeholder="Password">
			<span id="pwd_span"style="color: #666;"> &nbsp;</span>
			<button type="button" id="login">登&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;陆</button>
			<div class="error"><span>+</span></div>
		</div>
	</div>
</body>
</html>

